<template>
	<view class="AppH5login">
		<view class="h5login">
			<view class="login_image">
			</view>
			<view class="login_info">
				<view class="login_phone">
					账&nbsp;号:<input placeholder="请输入手机号" type="text" v-model="phone" />
				</view>
				<view class="login_phone">
					密&nbsp;码:<input placeholder="请输入密码" type="text" password v-model="password" />
				</view>
				<view class="viewview">
					<u-checkbox-group class="login_check" v-model="checked" size="22">
						<u-checkbox class="checked" activeColor="green" name="1">
						</u-checkbox>
					</u-checkbox-group>
					<span class="span">请点击并阅读<span @click="handleClick1">《服务协议》</span>,<span
							@click="handleClick2">《隐私政策》</span></span>
				</view>
				<view class="view">
					<view class="uni-btn-v">
						<button type="primary" @click="GoPhone">登录</button>
					</view>
					<view class="uni-btn-v1">
						<button type="primary" @click="goregister()">注册</button>
					</view>
				</view>
			</view>
		</view>
		<view class="img1"></view>
		<view class="img2"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				phone: '',
				password: '',
				tips2: '',
				checked: []
			}
		},
		methods: {
			handleClick1() {
				// 跳转用户协议
				uni.navigateTo({
					url: "/pages/userAgree/userAgree"
				})
			},
			handleClick2() {
				// 跳转隐私政策
				uni.navigateTo({
					url: "/pages/yinsi/yinsi"
				})
			},
			changeCheck() {
				this.checked = !this.checked;
			},
			codeChange2(text) {
				this.tips2 = text;
			},
			goregister() {
				uni.navigateTo({
					url: '/pages/register/register'
				})
			},
			GoPhone() {
				if (this.checked.length > 0) {
					this.$http({
						url: '/MemberLogin/appLoginPassword',
						data: {
							memberName: this.phone,
							password: this.password
						},
						method: 'POST'
					}).then(res => {
						if (res.data.code === 200) {
							uni.showToast({
								title: res.data.message,
								icon: 'success'
							})
							uni.setStorageSync('secretKey', res.data.data);
							uni.switchTab({
								url: '/pages/user/user'
							})
						} else {
							uni.showToast({
								title: res.data.message,
								icon: 'error'
							})
						}
					}).catch(err => {
						uni.showToast({
							title: err,
							icon: 'error'
						})
					})
				} else {
					uni.showToast({
						title: "请先阅读认养协议认养协议",
						icon: 'error',
					})
				}
			},
		},
		onShow() {
			this.tips2 = '获取验证码'
		}
	}
</script>

<style lang="less">
	@import './AppH5password.css';
</style>
